{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "names = [\"Alice\", \"Bob\", \"Charlie\"]\n",
    "scores = [85, 92, 78]\n",
    "\n",
    "print(dict(zip(names, scores)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [1, 2, 3]\n",
    "b = [\"a\", \"b\"]\n",
    "\n",
    "print(list(zip(a, b)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [1, 2, 3]\n",
    "b = [\"a\", \"b\", \"c\"]\n",
    "\n",
    "zipped = zip(a, b)\n",
    "a.append(4)\n",
    "b.append(\"d\")\n",
    "\n",
    "print(list(zipped))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Iterate over two lists simultaneously\n",
    "a = [1, 2, 3]\n",
    "b = [\"x\", \"y\", \"z\"]\n",
    "\n",
    "for num, char in zip(a, b):\n",
    "    print(f\"{num} -> {char}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "keys = [\"id\", \"name\", \"age\"]\n",
    "values: list[str | int] = [101, \"Alice\", 25]\n",
    "\n",
    "print(dict(zip(keys, values)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "zipped = [(1, \"a\"), (2, \"b\"), (3, \"c\")]\n",
    "unzipped = list(zip(*zipped))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from itertools import count\n",
    "\n",
    "a = count(1)  # Infinite iterator\n",
    "b = [\"x\", \"z\", \"y\"]  # Finite iterable\n",
    "\n",
    "print(list(zip(a, b)))  # Output: [(1, 'x'), (2, 'y'), (3, 'z')]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [1, 2, 3]\n",
    "b = [\"a\", \"b\", \"c\"]\n",
    "c: list[bool | None] = [True, False, None]\n",
    "\n",
    "print(list(zip(a, b, c)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [1, 2, 3]\n",
    "b = (\"x\", \"y\", \"z\")\n",
    "c: set[bool | None] = {True, False, None}\n",
    "\n",
    "print(list(zip(a, b, c)))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
